package com.zhaiweijia.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhaiweijia.dao.ArticleDao;
import com.zhaiweijia.entity.Article;
import com.zhaiweijia.entity.User;
import com.zhaiweijia.service.ArticleService;
@Service
public class ArticleServiceImpl implements ArticleService{
	@Autowired
	private ArticleDao articleDao;

	@Override
	public void add(Article article) {
		// TODO Auto-generated method stub
		articleDao.add(article);
	}

	@Override
	public PageInfo listByUser(Integer pageNum, Integer pageSize, User user) {
		PageHelper.startPage(pageNum, pageSize);
		List<Article> list=articleDao.listByUser(user);
		PageInfo info = new PageInfo(list);
		
		return info;
	}

	@Override
	public Article findDetailById(Integer id) {
		// TODO Auto-generated method stub
		return articleDao.findDetailById(id);
	}

	@Override
	public PageInfo list(Integer pageNum, Integer pageSize, Article article) {
		PageHelper.startPage(pageNum, pageSize);
		List<Article> list=articleDao.list(article);
		PageInfo info = new PageInfo(list);
		return info;
	}

	@Override
	public void update(Article article) {
		// TODO Auto-generated method stub
		articleDao.update(article);
	}

	@Override
	public PageInfo listByHits(Integer pageNum, Integer pageSize, Article article) {
		PageHelper.startPage(pageNum, pageSize);
		List<Article> list=articleDao.listByHits(article);
		PageInfo info = new PageInfo(list);
		return info;
	}
	
	
}
